import http from '@/utils/request'
//获取用户列表----分页
function gelUserListReq(per = 1, page = 10) {
  return http({
    method: 'post',
    url: ' /api/v1/admin/user',
    parmas: { per, page },
  })
}
//获取用户--用户名
function gelUserToUserNameReq(per = 1, page = 10, userName) {
  return http({
    method: 'post',
    url: ' /api/v1/admin/user',
    parmas: { per, page, userName },
  })
}
//获取用户信息--昵称
function gelUserToNickNameReq(per = 1, page = 10, nickName) {
  return http({
    method: 'post',
    url: ' /api/v1/admin/user',
    parmas: { per, page, nickName },
  })
}
//文件上传
function fileUploadReq(file) {
  const formData = new FormData()
  formData.append('file', file)
  return http({
    method: 'post',
    url: '/api/v1/common/upload_file',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: formData,
  })
}
// 修改用户信息
function ModifyUserReq(id, birthday, age, avatar, area, address, nickName, gender) {
  return http({
    method: 'put',
    url: '/api/v1/admin/user/' + id,
    data: { birthday, age, avatar, area, address, nickName, gender },
  })
}
//用户删除
function DelUserReq(id) {
  return http({
    method: 'delete',
    url: '/api/v1/admin/user/' + id,
  })
}
//用户锁定
function LockUserReq(id) {
  return http({
    method: 'put',
    url: '/api/v1/admin/user/' + id,
  })
}
//用户购物车列表 user为用户id
function getUserCartListReq(user) {
  return http({
    method: 'get',
    url: '/api/v1/admin/cart/info',
    params: { user },
  })
}
//用户购物车删除
function DelUserCartReq(id) {
  return http({
    method: 'delete',
    url: '/api/v1/admin/cart/' + id,
  })
}
//积分记录 user为用户id
function getScorelogReq(user) {
  return http({
    method: 'get',
    url: ' /api/v1/admin/scorelog/info',
    params:{user}
  })
}
export {
  gelUserListReq,
  gelUserToUserNameReq,
  gelUserToNickNameReq,
  ModifyUserReq,
  fileUploadReq,
  DelUserReq,
  LockUserReq,
  getUserCartListReq,
  DelUserCartReq,
  getScorelogReq
}
